package com.cet.designpatterns.iterator;

import java.util.Iterator;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-21 22:30
 **/
public class ComputerCollegeIterator implements Iterator {

    /**
     * 这里我们需要知道Department是以怎样的方式存放
     */
    private Department[] departments;
    private int position;

    public ComputerCollegeIterator(Department[] departments) {
        if (departments == null) {
            throw new NullPointerException();
        }
        this.departments = departments;
        position = 0;
    }

    @Override
    public boolean hasNext() {
        return position < departments.length;
    }

    @Override
    public Object next() {
        return departments[position++];
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
